package siruna.WE.DeviceDependent.AndroidFunctionBlocks;

import java.util.List;

import org.apache.http.MethodNotSupportedException;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Looper;

import siruna.WE.DeviceDependent.DeviceFunctionalBlock;
import siruna.WE.DeviceDependent.Global;
import siruna.WE.DeviceDependent.WidgetEngine1;
import siruna.WE.DeviceDependent.ContentProviders.GPSManager;
import siruna.WE.core.model.FunctionalBlock;

public class DeviceGPSProviderImpl extends DeviceFunctionalBlock {

	private Context context;

	@Override
	public byte[] toByteArray() throws MethodNotSupportedException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List toList() throws MethodNotSupportedException {
		// TODO Auto-generated method stub
		return null;
	}

	public DeviceGPSProviderImpl() {
		super();

	}

	public String toString() {

		GPSManager gm = new GPSManager();

		LocationManager myManager = (LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE);
		Location loc = myManager.getLastKnownLocation("gps");

		if (loc == null) {

			return "No GPS information available";
		} else {	
			double l = loc.getLatitude();
			double a = loc.getLongitude();

			return String.valueOf(l + " " + a);
		}

	}

	@Override
	public void setContext(Context c) {
		System.out.println("Contextxt gezet in DeviceGPSProviderImpl: "
				+ c.getPackageName());
		this.context = c;
	}

	@Override
	public String toHTML() {
		// TODO Auto-generated method stub
		return null;
	}

}
